﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package org.nickro.project.BulkLoad.loadingtypes {
    import flash.display.*;
    import flash.events.*;
    import org.nickro.project.BulkLoad.*;
    import flash.net.*;
    import flash.utils.*;

    public class ImageItem extends LoadingItem {

        public var loader:Loader;

        public function ImageItem(_arg1:URLRequest, _arg2:String, _arg3:String){
            specificAvailableProps = [BulkLoader.CONTEXT];
            super(_arg1, _arg2, _arg3);
        }
        override public function onErrorHandler(_arg1:ErrorEvent):void{
            super.onErrorHandler(_arg1);
        }
        override public function stop():void{
            try {
                if (this.loader){
                    this.loader.close();
                };
            } catch(e:Error) {
            };
            super.stop();
        }
        override public function load():void{
            super.load();
            this.loader = new Loader();
            this.loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler, false, 0, true);
            this.loader.contentLoaderInfo.addEventListener(Event.COMPLETE, this.onCompleteHandler, false, 0, true);
            this.loader.contentLoaderInfo.addEventListener(Event.INIT, this.onInitHandler, false, 0, true);
            this.loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, this.onErrorHandler, false, 100, true);
            this.loader.contentLoaderInfo.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecurityErrorHandler, false, 0, true);
            this.loader.contentLoaderInfo.addEventListener(Event.OPEN, onStartedHandler, false, 0, true);
            this.loader.contentLoaderInfo.addEventListener(HTTPStatusEvent.HTTP_STATUS, super.onHttpStatusHandler, false, 0, true);
            try {
                this.loader.load(url, _context);
            } catch(e:SecurityError) {
                onSecurityErrorHandler(_createErrorEvent(e));
            };
        }
        override public function destroy():void{
            this.stop();
            this.cleanListeners();
            _content = null;
            if (((((this.loader) && (this.loader.hasOwnProperty("unloadAndStop")))) && ((this.loader["unloadAndStop"] is Function)))){
                var _local1 = this.loader;
                _local1["unloadAndStop"](true);
            } else {
                if (((((this.loader) && (this.loader.hasOwnProperty("unload")))) && ((this.loader["unload"] is Function)))){
                    _local1 = this.loader;
                    _local1["unload"]();
                };
            };
            this.loader = null;
        }
        override public function _parseOptions(_arg1:Object):Array{
            _context = ((_arg1[BulkLoader.CONTEXT]) || (null));
            return (super._parseOptions(_arg1));
        }
        public function getDefinitionByName(_arg1:String):Object{
            if (this.loader.contentLoaderInfo.applicationDomain.hasDefinition(_arg1)){
                return (this.loader.contentLoaderInfo.applicationDomain.getDefinition(_arg1));
            };
            return (null);
        }
        override public function isImage():Boolean{
            return ((type == BulkLoader.TYPE_IMAGE));
        }
        override public function onCompleteHandler(_arg1:Event):void{
            var evt:* = _arg1;
            try {
                _content = this.loader.content;
                super.onCompleteHandler(evt);
            } catch(e:SecurityError) {
                _content = loader;
                super.onCompleteHandler(evt);
            };
        }
        override public function cleanListeners():void{
            var _local1:Object;
            if (this.loader){
                _local1 = this.loader.contentLoaderInfo;
                _local1.removeEventListener(ProgressEvent.PROGRESS, onProgressHandler, false);
                _local1.removeEventListener(Event.COMPLETE, this.onCompleteHandler, false);
                _local1.removeEventListener(Event.INIT, this.onInitHandler, false);
                _local1.removeEventListener(IOErrorEvent.IO_ERROR, this.onErrorHandler, false);
                _local1.removeEventListener(BulkLoader.OPEN, onStartedHandler, false);
                _local1.removeEventListener(HTTPStatusEvent.HTTP_STATUS, super.onHttpStatusHandler, false);
            };
        }
        override public function isSWF():Boolean{
            return ((type == BulkLoader.TYPE_MOVIECLIP));
        }
        public function _onHttpStatusHandler(_arg1:HTTPStatusEvent):void{
            _httpStatus = _arg1.status;
            dispatchEvent(_arg1);
        }
        public function onInitHandler(_arg1:Event):void{
            dispatchEvent(_arg1);
        }

    }
}//package org.nickro.project.BulkLoad.loadingtypes 
